package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysFileRsp;
import com.ruoyi.system.service.ISysFileRspService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 中移接口返回Controller
 * 
 * @author ruoyi
 * @date 2025-01-15
 */
@RestController
@RequestMapping("/system/rsp")
public class SysFileRspController extends BaseController
{
    @Autowired
    private ISysFileRspService sysFileRspService;

    /**
     * 查询中移接口返回列表
     */
    @PreAuthorize("@ss.hasPermi('system:rsp:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysFileRsp sysFileRsp)
    {
        startPage();
        List<SysFileRsp> list = sysFileRspService.selectSysFileRspList(sysFileRsp);
        return getDataTable(list);
    }



    /**
     * 导出中移接口返回列表
     */
    @PreAuthorize("@ss.hasPermi('system:rsp:export')")
    @Log(title = "中移接口返回", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysFileRsp sysFileRsp)
    {
        List<SysFileRsp> list = sysFileRspService.selectSysFileRspList(sysFileRsp);
        ExcelUtil<SysFileRsp> util = new ExcelUtil<SysFileRsp>(SysFileRsp.class);
        util.exportExcel(response, list, "中移接口返回数据");
    }

    /**
     * 获取中移接口返回详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rsp:query')")
    @GetMapping(value = "/{empowerNo}")
    public AjaxResult getInfo(@PathVariable("empowerNo") String empowerNo)
    {
        return success(sysFileRspService.selectSysFileRspByEmpowerNo(empowerNo));
    }

    /**
     * 新增中移接口返回
     */
    @PreAuthorize("@ss.hasPermi('system:rsp:add')")
    @Log(title = "中移接口返回", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysFileRsp sysFileRsp)
    {
        return toAjax(sysFileRspService.insertSysFileRsp(sysFileRsp));
    }

    /**
     * 修改中移接口返回
     */
    @PreAuthorize("@ss.hasPermi('system:rsp:edit')")
    @Log(title = "中移接口返回", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysFileRsp sysFileRsp)
    {
        return toAjax(sysFileRspService.updateSysFileRsp(sysFileRsp));
    }

    /**
     * 修改中移接口返回
     */
//    @PreAuthorize("@ss.hasPermi('system:rsp:insert')")
    @Log(title = "中移接口返回", businessType = BusinessType.INSERT)
//    @GetMapping
    @GetMapping(value = "/mobile/{mobile}")
    public AjaxResult saveMobile(@PathVariable("mobile") String mobile)
    {
        return toAjax(sysFileRspService.saveMobile(mobile,1L));
    }

    /**
     * 删除中移接口返回
     */
    @PreAuthorize("@ss.hasPermi('system:rsp:remove')")
    @Log(title = "中移接口返回", businessType = BusinessType.DELETE)
	@DeleteMapping("/{empowerNos}")
    public AjaxResult remove(@PathVariable String[] empowerNos)
    {
        return toAjax(sysFileRspService.deleteSysFileRspByEmpowerNos(empowerNos));
    }
}
